/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2018-11-06     SummerGift   first version
 * 2023-12-03     Meco Man     support nano version
 */

#include <board.h>
#include <rtthread.h>
#include <drv_gpio.h>
#ifndef RT_USING_NANO
#include <rtdevice.h>
#include <rtdef.h>
#include "serial_echo.h"
#endif /* RT_USING_NANO */

/* defined the USER LED2 pin: PB7 */
#define LED2_PIN               GET_PIN(A, 1)

#define ECHO_TASK_STACK         256
#define ECHO_TASK_PRIORATY      20
#define ECHO_TASK_SLICE         20

static rt_thread_t echo_thread;
static rt_thread_t echo_send_thread;
extern struct rt_completion recv_ok;
int main(void)
{
    rt_uint32_t result = 0;

    //完成量初始化
    rt_completion_init(&recv_ok);
	
	echo_thread = rt_thread_create("uart_echo_recv",echoRecvTaskEntry,NULL,ECHO_TASK_STACK,ECHO_TASK_PRIORATY,ECHO_TASK_SLICE);
    RT_ASSERT(echo_thread != RT_NULL);
    result = rt_thread_startup(echo_thread);
    RT_ASSERT(result == RT_EOK);

    echo_send_thread = rt_thread_create("uart_echo_send",echoSendTaskEntry,NULL,ECHO_TASK_STACK,ECHO_TASK_PRIORATY,ECHO_TASK_SLICE);
    RT_ASSERT(echo_send_thread != RT_NULL);
    result = rt_thread_startup(echo_send_thread);
    RT_ASSERT(result == RT_EOK);

	/* set LED0 pin mode to output */
    rt_pin_mode(LED2_PIN, PIN_MODE_OUTPUT);
    while (1)
    {
        rt_pin_write(LED2_PIN, PIN_HIGH);
        rt_thread_mdelay(500);
        rt_pin_write(LED2_PIN, PIN_LOW);
        rt_thread_mdelay(500);
    }
}
